<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>C MIP-SDK: mip_sdk_user_functions.c File Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">C MIP-SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">mip_sdk_user_functions.c File Reference</div>  </div>
</div>
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="mip__sdk__user__functions_8h_source.html">mip_sdk_user_functions.h</a>&quot;</code><br/>
<code>#include &lt;windows.h&gt;</code><br/>
</div><table class="memberdecls">
<tr><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u16&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#a99bf4e218ebbb9a59c2424fc4111e1f6">mip_sdk_port_open</a> (void **port_handle, int port_num, int baudrate)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u16&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#a819ea2df6fcffdd5038a1074a6975795">mip_sdk_port_close</a> (void *port_handle)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u16&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#a05adcb952bf1c72462e85338f647ebca">mip_sdk_port_write</a> (void *port_handle, u8 *buffer, u32 num_bytes, u32 *bytes_written, u32 timeout_ms)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u16&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#a063fe61eac45cf4c7454998bc8f5a95c">mip_sdk_port_read</a> (void *port_handle, u8 *buffer, u32 num_bytes, u32 *bytes_read, u32 timeout_ms)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#ac2401652177325f14659a7b77def2a7a">mip_sdk_port_read_count</a> (void *port_handle)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top">u32&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="mip__sdk__user__functions_8c.html#a4a12b7dbdee5143de70bc30cf2006df1">mip_sdk_get_time_ms</a> ()</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><dl class="author"><dt><b>Author:</b></dt><dd>Nathan Miller </dd></dl>
<dl class="version"><dt><b>Version:</b></dt><dd>1.1 </dd></dl>
</div><hr/><h2>Function Documentation</h2>
<a class="anchor" id="a4a12b7dbdee5143de70bc30cf2006df1"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_get_time_ms" ref="a4a12b7dbdee5143de70bc30cf2006df1" args="()" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 mip_sdk_get_time_ms </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific Call to get the current time in milliseconds. </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Current time in milliseconds. </dd></dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>1) This value should no roll-over in short periods of time (e.g. minutes)<br/>
 2) Most systems have a millisecond counter that rolls-over every 32 bits<br/>
 (e.g. 49.71 days roll-over period, with 1 millisecond LSB)<br/>
 3) An absolute reference is not required since this function is<br/>
 used for relative time-outs.<br/>
 4) The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
<a class="anchor" id="a819ea2df6fcffdd5038a1074a6975795"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_port_close" ref="a819ea2df6fcffdd5038a1074a6975795" args="(void *port_handle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16 mip_sdk_port_close </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>port_handle</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific port close function </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">MIP_USER_FUNCTION_ERROR</td><td>When there is a problem closing the port.<br/>
 </td></tr>
    <tr><td class="paramname">MIP_USER_FUNCTION_OK</td><td>The close was successful.<br/>
 </td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
<a class="anchor" id="a99bf4e218ebbb9a59c2424fc4111e1f6"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_port_open" ref="a99bf4e218ebbb9a59c2424fc4111e1f6" args="(void **port_handle, int port_num, int baudrate)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16 mip_sdk_port_open </td>
          <td>(</td>
          <td class="paramtype">void **&#160;</td>
          <td class="paramname"><em>port_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>port_num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>baudrate</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific communications port open. </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">int</td><td>port_num - port number (as recognized by the operating system.) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">int</td><td>baudrate - baudrate of the com port. </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">MIP_USER_FUNCTION_ERROR</td><td>When there is a problem opening the port.<br/>
 </td></tr>
    <tr><td class="paramname">MIP_USER_FUNCTION_OK</td><td>The open was successful.<br/>
 </td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
<a class="anchor" id="a063fe61eac45cf4c7454998bc8f5a95c"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_port_read" ref="a063fe61eac45cf4c7454998bc8f5a95c" args="(void *port_handle, u8 *buffer, u32 num_bytes, u32 *bytes_read, u32 timeout_ms)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16 mip_sdk_port_read </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>port_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>num_bytes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32 *&#160;</td>
          <td class="paramname"><em>bytes_read</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>timeout_ms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific Port Write Function. </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u8</td><td>*buffer - buffer containing num_bytes of data </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u32</td><td>num_bytes - the number of bytes to write to the port </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">u32</td><td>*bytes_read - the number of bytes actually read from the device </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u32</td><td>timeout_ms - the read timeout </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">MIP_USER_FUNCTION_ERROR</td><td>When there is a problem communicating with the port.<br/>
 </td></tr>
    <tr><td class="paramname">MIP_USER_FUNCTION_OK</td><td>The read was successful.<br/>
 </td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
<a class="anchor" id="ac2401652177325f14659a7b77def2a7a"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_port_read_count" ref="ac2401652177325f14659a7b77def2a7a" args="(void *port_handle)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u32 mip_sdk_port_read_count </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>port_handle</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific Function to Get the Number of Bytes Waiting on the Port. </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>Number of bytes waiting on the port,<br/>
 0, if there is an error. </dd></dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
<a class="anchor" id="a05adcb952bf1c72462e85338f647ebca"></a><!-- doxytag: member="mip_sdk_user_functions.c::mip_sdk_port_write" ref="a05adcb952bf1c72462e85338f647ebca" args="(void *port_handle, u8 *buffer, u32 num_bytes, u32 *bytes_written, u32 timeout_ms)" -->
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">u16 mip_sdk_port_write </td>
          <td>(</td>
          <td class="paramtype">void *&#160;</td>
          <td class="paramname"><em>port_handle</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u8 *&#160;</td>
          <td class="paramname"><em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>num_bytes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32 *&#160;</td>
          <td class="paramname"><em>bytes_written</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">u32&#160;</td>
          <td class="paramname"><em>timeout_ms</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div>
<div class="memdoc">
<h2><a class="anchor" id="DESCRIPTION"></a>
DESCRIPTION</h2>
<p>Target-Specific Port Write Function. </p>
<h2><a class="anchor" id="DETAILS"></a>
DETAILS</h2>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">void</td><td>*port_handle - target-specific port handle pointer (user needs to allocate memory for this) </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u8</td><td>*buffer - buffer containing num_bytes of data </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u32</td><td>num_bytes - the number of bytes to write to the port </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">u32</td><td>*bytes_written - the number of bytes actually written to the port </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">u32</td><td>timeout_ms - the write timeout </td></tr>
  </table>
  </dd>
</dl>
<dl><dt><b>Return values:</b></dt><dd>
  <table class="retval">
    <tr><td class="paramname">MIP_USER_FUNCTION_ERROR</td><td>When there is a problem communicating with the port.<br/>
 </td></tr>
    <tr><td class="paramname">MIP_USER_FUNCTION_OK</td><td>The write was successful.<br/>
 </td></tr>
  </table>
  </dd>
</dl>
<h2><a class="anchor" id="NOTES"></a>
NOTES</h2>
<p>The user should copy the <code><a class="el" href="mip__sdk__user__functions_8c.html">mip_sdk_user_functions.c</a></code> file to their project directory and<br/>
 edit it as needed to support their target operating system. </p>

</div>
</div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Fri May 30 2014 17:03:33 for C MIP-SDK by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
